/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JAgregarSala.java
 *
 * Created on 24-nov-2010, 8:45:00
 */

package IGU;

import datos.Cine;
import datos.ListaFuncion;
import javax.swing.JFrame;
import logica.Datos;
import logica.FuncionesGUI;

/**
 *
 * @author Cristian
 */
public class AgregarSala extends javax.swing.JFrame {

        private Cine elCine;

    public AgregarSala() {
        initComponents();
        initMyOwnComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTid = new javax.swing.JTextField();
        jTCapacidad = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jBAgregarSala = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jTVIP = new javax.swing.JToggleButton();
        jLabel2 = new javax.swing.JLabel();
        jLCine = new javax.swing.JLabel();
        jCBListaDeCines = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jTid.setName("jTid"); // NOI18N
        getContentPane().add(jTid, new org.netbeans.lib.awtextra.AbsoluteConstraints(112, 62, 84, -1));

        jTCapacidad.setName("jTCapacidad"); // NOI18N
        getContentPane().add(jTCapacidad, new org.netbeans.lib.awtextra.AbsoluteConstraints(112, 100, 84, -1));

        jPanel1.setBackground(new java.awt.Color(51, 51, 51));
        jPanel1.setName("jPanel1"); // NOI18N

        jBAgregarSala.setText("Aceptar");
        jBAgregarSala.setName("jBAgregarSala"); // NOI18N
        jBAgregarSala.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBAgregarSalaActionPerformed(evt);
            }
        });

        jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IGU/imagen/film.png"))); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jLabel10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IGU/imagen/movies.png"))); // NOI18N
        jLabel10.setText("jLabel10");
        jLabel10.setName("jLabel10"); // NOI18N

        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("VIP:");
        jLabel4.setName("jLabel4"); // NOI18N

        jTVIP.setText("VIP");
        jTVIP.setName("jTVIP"); // NOI18N
        jTVIP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTVIPActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Agregar Una Sala Nueva");
        jLabel2.setName("jLabel2"); // NOI18N

        jLCine.setForeground(new java.awt.Color(255, 255, 255));
        jLCine.setText("Cine:");
        jLCine.setName("jLCine"); // NOI18N

        jCBListaDeCines.setName("jCBListaDeCines"); // NOI18N
        jCBListaDeCines.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCBListaDeCinesActionPerformed(evt);
            }
        });

        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("ID:");
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("Capacidad:");
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("Personas");
        jLabel8.setName("jLabel8"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(40, 40, 40)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(130, 130, 130)
                                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel1))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel8)
                                .addGap(87, 87, 87))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(69, 69, 69)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLCine, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jCBListaDeCines, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addGap(18, 18, 18)
                                .addComponent(jTVIP)))))
                .addGap(5, 5, 5)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(60, 60, 60)
                        .addComponent(jBAgregarSala, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(40, 40, 40)
                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(jLabel2)
                        .addGap(28, 28, 28)
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(jLabel8))
                        .addGap(26, 26, 26)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jTVIP))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLCine)
                            .addComponent(jCBListaDeCines, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(230, 230, 230)
                        .addComponent(jBAgregarSala))
                    .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(100, 100, 100)
                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(17, 17, 17))
        );

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 560, 270));

        pack();
    }// </editor-fold>//GEN-END:initComponents

        private void initMyOwnComponents()
    { 
        FuncionesGUI.inicializarCombo (jCBListaDeCines, "Seleccione un Cine");
        FuncionesGUI.cargarListaCinesEnCombo(jCBListaDeCines, false);

    }
 private boolean vip=false;
    private void jTVIPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTVIPActionPerformed
        vip= jTVIP.isSelected();
        if (vip == true)
            System.out.println("es vip\n");
        else System.out.println("no es vip\n");
        // TODO add your handling code here:
    }//GEN-LAST:event_jTVIPActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        FuncionesGUI.habilitarVentana(this.ventanaPadre, true, true);
        this.dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_formWindowClosing

    private void jBAgregarSalaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBAgregarSalaActionPerformed
    if (Datos.getListaCine().obtenerCine(jCBListaDeCines.getSelectedIndex()-1)!=null)
    System.out.println("Aqui HAY un cine cargado!!!!!!!!/n");
    System.out.println("posicion del cine antes de agregarle la sala: "+ (jCBListaDeCines.getSelectedIndex()-1));

        FuncionesGUI.AgregarNuevaSala(jCBListaDeCines.getSelectedIndex()-1,jTid,jTCapacidad,Datos.getListaCine().obtenerCine(jCBListaDeCines.getSelectedIndex()-1),vip);


        FuncionesGUI.habilitarVentana(this.ventanaPadre, true, true);
        this.dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_jBAgregarSalaActionPerformed

    private void jCBListaDeCinesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCBListaDeCinesActionPerformed
        elCine=FuncionesGUI.DameElCine(jCBListaDeCines.getSelectedIndex()-1);
    }//GEN-LAST:event_jCBListaDeCinesActionPerformed


        private JFrame ventanaPadre;
        public JFrame getVentanaPadre()
    {
        return ventanaPadre;
    }
    public void setVentanaPadre(JFrame ventanaPadre)
    {
        this.ventanaPadre = ventanaPadre;
    }


    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new AgregarSala().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBAgregarSala;
    private javax.swing.JComboBox jCBListaDeCines;
    private javax.swing.JLabel jLCine;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jTCapacidad;
    private javax.swing.JToggleButton jTVIP;
    private javax.swing.JTextField jTid;
    // End of variables declaration//GEN-END:variables

}
